/**
 * Funcionario Funcionario.java
 */

package CCT220_Trabalho05_13106_Q1.model;


import java.util.Iterator;
import java.util.Vector;


/**
 * </br>******************************
 * </br>Project: CCT220
 * </br>Package: CCT220_Trabalho05_13106.model
 * </br>Class: Funcionario
 * </br>Last Change: 11/10/2011 21:34:26 by marcel
 * </br>Description: Entity: Abstract Class Funcionario
 * </br>******************************</br>
 * 
 * @author marcel
 * @author 13106
 * 
 */
public abstract class Funcionario {
	/**
	 * int
	 */
	private final int               codigo;
	/**
	 * String
	 */
	private final String            nome;
	/**
	 * Vector<PontoFunc>
	 */
	private final Vector<PontoFunc> pontoMensal;


	/**
	 * </br>******************************
	 * </br>Constructor for
	 * </br>Package: CCT220_Trabalho05_13106.model
	 * </br>Class: Funcionario
	 * </br>LastChange: 11/10/2011 21:37:58 by marcel
	 * </br>******************************</br>
	 * 
	 * @param codigo
	 * @param nome
	 */
	public Funcionario(int codigo, String nome) {

		super();
		this.codigo = codigo;
		this.nome = nome;
		this.pontoMensal = new Vector<PontoFunc>();
	}


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Trabalho05_13106.model
	 * </br>Class: Funcionario
	 * </br>Method: getCodigo
	 * </br>Last Change: 11/10/2011 21:38:40 by marcel
	 * </br>Description: Getter for codigo
	 * </br>******************************</br>
	 * 
	 * @return the codigo
	 */
	public int getCodigo() {

		return codigo;
	}


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Trabalho05_13106.model
	 * </br>Class: Funcionario
	 * </br>Method: getNome
	 * </br>Last Change: 11/10/2011 21:38:40 by marcel
	 * </br>Description: Getter for nome
	 * </br>******************************</br>
	 * 
	 * @return the nome
	 */
	public String getNome() {

		return nome;
	}


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Trabalho05_13106.model
	 * </br>Class: Funcionario
	 * </br>Method: getPontoMensal
	 * </br>Last Change: 11/10/2011 21:38:40 by marcel
	 * </br>Description: Getter for pontoMensal
	 * </br>******************************</br>
	 * 
	 * @return the pontoMensal
	 */
	public Vector<PontoFunc> getPontoMensal() {

		return pontoMensal;
	}


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Trabalho05_13106.model
	 * </br>Class: Funcionario
	 * </br>Method: adicionaPonto
	 * </br>Last Change: 11/10/2011 21:59:56 by marcel
	 * </br>Description: Add a PontoFunc to pontoMensal
	 * </br>******************************</br>
	 * 
	 * @param pMes
	 * @param pAno
	 */
	public void adicionaPonto(int pMes, int pAno) {

		PontoFunc p = new PontoFunc(pMes, pAno);
		this.pontoMensal.add(p);
	}


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Trabalho05_13106.model
	 * </br>Class: Funcionario
	 * </br>Method: lancaFaltas
	 * </br>Last Change: 11/10/2011 21:41:00 by marcel
	 * </br>Description: Add pFaltas ass nroFaltas in PontoFunc
	 * </br>******************************</br>
	 * 
	 * @param pMes
	 * @param pAno
	 * @param pFaltas
	 */
	public void lancaFaltas(int pMes, int pAno, int pFaltas) {

		Iterator<PontoFunc> it = this.pontoMensal.iterator();
		while (it.hasNext()) {
			PontoFunc p = it.next();
			if (p.getAno() == pAno && p.getMes() == pMes) {
				p.lancaFaltas(pFaltas);
			}
		}
	}


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Trabalho05_13106.model
	 * </br>Class: Funcionario
	 * </br>Method: lancaAtrasos
	 * </br>Last Change: 11/10/2011 21:41:02 by marcel
	 * </br>Description: Add pAtrasos ass nroAtrasos in PontoFunc
	 * </br>******************************</br>
	 * 
	 * @param pMes
	 * @param pAno
	 * @param pAtrasos
	 */
	public void lancaAtrasos(int pMes, int pAno, int pAtrasos) {

		Iterator<PontoFunc> it = this.pontoMensal.iterator();
		while (it.hasNext()) {
			PontoFunc p = it.next();
			if (p.getAno() == pAno && p.getMes() == pMes) {
				p.lancaAtrasos(pAtrasos);
			}
		}
	}


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Trabalho05_13106.model
	 * </br>Class: Funcionario
	 * </br>Method: imprimeFolha
	 * </br>Last Change: 11/10/2011 21:41:05 by marcel
	 * </br>Description: Print
	 * </br>******************************</br>
	 * 
	 * @param pMes
	 * @param pAno
	 * @return String
	 */
	public String imprimeFolha(int pMes, int pAno) {

		String ret = "Folha de " + pMes + "/" + pAno + " do Funcionario: "
		        + this.nome + "-" + this.codigo + "\n";
		Iterator<PontoFunc> it = pontoMensal.iterator();
		while (it.hasNext()) {
			PontoFunc p = it.next();
			if (p.getAno() == pAno && p.getMes() == pMes) {
				ret += " teve " + p.getNroAtrasos() + " atrasos e "
				        + p.getNroFaltas() + " faltas.";
			}
		}
		return ret;
	}


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Trabalho05_13106.model
	 * </br>Class: Funcionario
	 * </br>Method: calculaSalario
	 * </br>Last Change: 11/10/2011 21:43:08 by marcel
	 * </br>Description: Calculate the liquid slary
	 * </br>******************************</br>
	 * 
	 * @param pMes
	 * @param pAno
	 * @return Calculated salary
	 */
	public abstract double calculaSalario(int pMes, int pAno);


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Trabalho05_13106.model
	 * </br>Class: Funcionario
	 * </br>Method: calculaBonus
	 * </br>Last Change: 11/10/2011 21:43:11 by marcel
	 * </br>Description: Calculate the bonus
	 * </br>******************************</br>
	 * 
	 * @param pMes
	 * @param pAno
	 * @return Calculated bonus
	 */
	public abstract double calculaBonus(int pMes, int pAno);

}
